#include "addbuildingdialog.h"
#include "ui_addbuildingdialog.h"

addBuildingDialog::addBuildingDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::addBuildingDialog)
{
    ui->setupUi(this);
    
    ui->lineEdit->setText("新建建筑");
    
    connect(ui->cancelBtn, SIGNAL(clicked(bool)), this, SLOT(close()));
    connect(ui->lineEdit, SIGNAL(textChanged(QString)), SLOT(updateBtn()));
    connect(ui->lineEdit, SIGNAL(textEdited(QString)), SLOT(getBuildingName()));
    connect(ui->OKBtn, SIGNAL(clicked(bool)), this, SLOT(accept()));
}

addBuildingDialog::~addBuildingDialog()
{
    delete ui;
}

void addBuildingDialog::updateBtn()
{
    if(ui->lineEdit->text().isEmpty())
        ui->OKBtn->setEnabled(false);
    else {
        ui->OKBtn->setEnabled(true);
    }
}

void addBuildingDialog::getBuildingName()
{
    if(!ui->lineEdit->text().isEmpty())
        this->buildingName = ui->lineEdit->text();
}
